package io.gitee.kotle.demo.doc

import android.view.View
import io.gitee.kotle.android.adapter.RecyclerViewHolder
import io.gitee.kotle.android.adapter.recyclerViewAdapter
import io.gitee.kotle.android.utils.setImageByCoil
import io.gitee.kotle.demo.databinding.HolderDemoBinding

class DemoHolder : RecyclerViewHolder<DemoBean, HolderDemoBinding> {
    companion object {

        fun createAdapter() = recyclerViewAdapter(DemoHolder::class.java, ::onSame, ::onSame)

        private fun onSame(old: DemoBean?, new: DemoBean?): Boolean {
            return old?.url == new?.url
        }
    }

    constructor(binding: HolderDemoBinding) : super(binding)
    constructor(itemView: View) : super(itemView)

    override fun bindData(data: DemoBean) {
        mBinding.root.setImageByCoil(data.url)
    }
}

